package com.guoyansoft.model.service.impl;

import com.guoyansoft.config.R;
import com.guoyansoft.model.dao.DistrictDao;
import com.guoyansoft.model.pojo.District;
import com.guoyansoft.model.service.DistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：zyx
 * @date ：Created in 2023-05-04-19:45
 * @description：
 * @modified By：
 * @version: $
 */
@Service
public class DistrictServiceImpl implements DistrictService {
    @Autowired
    private DistrictDao districtDao;
    @Override
    public R queryAll() {
        List<District> districts = districtDao.selectAll();
        return R.suc(districts);
    }

    @Override
    public District queryByDistrict(String district) {
        District district1 = districtDao.selectByDistrict(district);
        return district1;
    }

    @Override
    public R queryByPage(Map<String, Object> params) {
        Long total = districtDao.selectTotal(params);
        List<District> districtList = districtDao.selectByPage(params);
        return R.suc(total,districtList);
    }


    @Override
    public R save(District district) {
        Long row = districtDao.insert(district);
        return row>0?R.suc():R.fail();
    }

    @Override
    public R drop(Integer[] id) {
        Long row = districtDao.delete(id);
        return row>0?R.suc():R.fail();
    }

    @Override
    public R update(District district) {
        Long row = districtDao.update(district);
        return row>0?R.suc():R.fail();
    }
}
